#!/usr/bin/env python
#coding=utf-8
import parse
import threading
import wx

class RegisterThread(threading.Thread):  
    def __init__(self, window, web, inviteUrl, info):
        threading.Thread.__init__(self)
        self.window = window
        self.web = web
        self.inviteUrl = inviteUrl
        self.info = info
    
    def run(self): 
        wx.CallAfter(self.window.messageCall, u'正在提交小号信息')
        id = self.inviteUrl['id']
        sid = self.inviteUrl['sid']
        code = self.inviteUrl['code']
        f = self.web.reg(id, sid, code, self.info)
        exception = parse.parseReg(f)
        if exception:
            wx.CallAfter(self.window.infoCall, exception)
            wx.CallAfter(self.window.getCode)
        else:
            wx.CallAfter(self.window.infoCall, u'小号申请成功')
            wx.CallAfter(self.window.regSucessCall)
            wx.CallAfter(self.window.addUserCall, self.info['email'], self.info['pwd'])
            
             
            
